﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 策略模式
{
    internal class CashReturn : CashSuper
    {
        private double moneyCondition = 0d;

        private double moneyReturn = 0d;

        public CashReturn(string condition,string returnMoney)
        {
            this.moneyCondition = double.Parse(condition);
            this.moneyReturn = double.Parse(returnMoney);
        }

        public override double AcceptCash(double money)
        {
            double result = money;
            if (money>this.moneyCondition)
            {
                result = money - Math.Floor(money / this.moneyCondition) * this.moneyReturn;
            }

            return result;
        }
    }
}
